const config = require('../config');

const loginApiModule = require('../../api/login');

function getToken() {
  return new Promise(async (resolve, reject) => {
    let tokenParam = {
      grant_type: "client_credential",
      appid: config.APPID,
      secret: config.SECRET,
    }
    try {
      let tokenData = await loginApiModule.getToken(tokenParam);
      resolve(tokenData.access_token);
    } catch (error) {
      reject(error);
    }
  })
}

module.exports = {
  getToken
}